/*
 * Copyright 2007-2009 Thomas Krause (thomas@berlin-reloaded.de)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.gidoo.cms.editor.edit;

import org.apache.wicket.markup.html.panel.Panel;

/**
 * This abstract class must be extended by every editor that should be usable
 * within the editor-UI of gidooCMS. <br><br>
 * 
 * <b>IMPORTANT: </b> In order to ease instantiation this class always has an
 * empty constructor. Since this class extends <code>Panel</code> we have to
 * provide a Wicket-ID. The Wicket-ID of this component is always the same
 * and currently it is "<code>gidooCMSEditorComponent</code>".
 * Please notice that it
 * is only possible to have one editor on a page at the same time. 
 * 
 * @author <a href="mailto:thomas@berlin-reloaded.de">Thomas Krause</a>
 */
public abstract class EditorComponent extends Panel
{
  /** The Wicket-ID used by this component.*/
  public static final String wicketID = "gidooCMSEditorComponent";
  
  public EditorComponent()
  {
    super(wicketID);
  }
  
  /** Get the current XML-source as text. */
  abstract public String getText();
  
  /** Set the new XML-source. */
  abstract public void setText(String newText);
    
  /** Returns true if the parent component should provide preview-function. */
  abstract public boolean isPreviewFunctionNeeded();
  
  /** Enable or disable all component belonging to this editor */
  abstract public void enableComponents(boolean enable);
  
  /** Gets a specific default content of the editor field if the page is new */
  abstract public String getDefaultXml();

  /**
   * Returns a javascript that should be executed every time before one of the
   * submitting buttons is pressed.
   * Useful e.g. for (not too frequent) update of the text field.
   */
  public String getJavaScriptBeforeSubmit()
  {
    return null;
  }

}
